package com.ninetaildemonfox.zdl.socialproject.mvp.ui.activity;

import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.kongzue.dialog.v3.WaitDialog;
import com.ninetaildemonfox.zdl.socialproject.base.BaseActivity;
import com.ninetaildemonfox.zdl.socialproject.BuildConfig;
import com.ninetaildemonfox.zdl.socialproject.R;
import com.ninetaildemonfox.zdl.socialproject.mvp.contract.AboutUsContract;
import com.ninetaildemonfox.zdl.socialproject.mvp.presenter.AboutUsPresenter;
import com.ninetaildemonfox.zdl.socialproject.utils.ToastUtil;

import java.util.Map;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @author NineTailDemonFox
 * @date 2019/7/24 14:00
 * 功能描述： 关于我们
 * 联系方式：1037438704@qq.com
 */

public class AboutUsActivity extends BaseActivity implements AboutUsContract {

    @BindView(R.id.image_left_finish)
    ImageView imageleftFinish;
    @BindView(R.id.text_center)
    TextView textCenter;
    @BindView(R.id.text_right)
    TextView textRight;
    @BindView(R.id.text_agreement)
    TextView textAgreement;
    @BindView(R.id.text_company)
    TextView textCompany;
    @BindView(R.id.text_phone)
    TextView textPhone;
    @BindView(R.id.text_version)
    TextView textVersion;
    @BindView(R.id.text_qq)
    TextView textQq;
    @BindView(R.id.text_app_introduce)
    TextView text_app_introduce;
    private AboutUsPresenter presenter;
    private String aeclare;


    @Override
    protected int getLayoutResource() {
        return R.layout.activity_about_us;
    }

    @Override
    protected void onInitialization(Bundle bundle) {
        presenter = new AboutUsPresenter(this, me);
        presenter.getAboutUs();
        textCenter.setText("关于我们");
        imageleftFinish.setVisibility(View.VISIBLE);
        PackageManager packageManager = getPackageManager();
        // getPackageName()是你当前类的包名，0代表是获取版本信息
        String versionName = BuildConfig.VERSION_NAME;
        textVersion.setText("V" + versionName);

    }

    @OnClick({R.id.image_left_finish, R.id.text_agreement})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.image_left_finish:
                finish();
                break;
            case R.id.text_agreement:
                //协议及声明
                if (aeclare == null) {
                    ToastUtil.show("没有获取到协议");
                    return;
                }

                DetailsWebViewActivity.start(this, 2, aeclare);
                break;
            default:
        }
    }

    @Override
    public void Success(Map<String, String> map) {
        textCompany.setText(map.get("company"));
        textPhone.setText(map.get("tel"));
        textQq.setText(map.get("qq"));
        aeclare = map.get("declare");
        text_app_introduce.setText(map.get("app_introduce"));
    }

    @Override
    public void Failed(String msg) {

    }

    @Override
    public void showLoading() {
        WaitDialog.show(me, "");
    }
}
